package com.ioudi.digu.dao.support;

import org.hibernate.Query;

public class MessagerPossessQuerySupport extends AbstractQuerySupport
{
	protected void createQueryItem(Query query, String key, int index, Object value)
	{
		if(key.equals("payFored"))
		{
			query.setBoolean(index, (Boolean)value);
		}
		else if(key.equals("rendererURL"))
		{
			if(value instanceof Boolean)
			{
				query.setString(index, (Boolean)value ? "" : "dd");
			}	
		}
		else
		{
			query.setString(index, String.valueOf(value));
		}
	}
	
	protected String getStatementItemField(String key)
	{	
		if(key.equals("messagerName"))
		{
			return "messager.name";
		}
		if(key.equals("contentType"))
		{
			return "messager.contentType";
		}
		if(key.equals("rendererURL"))
		{
			return "messager.rendererURL";
		}
		return key;
	}
	
	protected String getStatementItemOperator(String key, Object value)
	{
		if(key.equals("rendererURL"))
		{
			return "!=";
		}
		return "=";
	}
}
